<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        <div>用户名 <input type="text" v-model="username" id="username" ref="username"></div>
        <button @click="getValue">赋值</button>
    </div>

</body>
<script>
    new Vue({
        el: "#app",
        data: {
            username: "leson"
        },
        methods: {
            getValue() {
                this.username = "lala";

                // setTimeout(()=>{
                //     let usernameInput =  this.$refs.username;
                // console.log(usernameInput.value);//leson
                // },0)  
                this.$nextTick(() => {
                    let usernameInput = this.$refs.username;
                    console.log(usernameInput.value);//leson
                })
            }
        }
    })
    //异步:微任务  时间不定  宏任务 可以指定时间

</script>

</html>